package com.moorror.codegenvel.utils;

import java.lang.reflect.Array;
import java.util.List;

/**
 * @Author jiyanghuang
 * @Date 2024/5/18 11:09
 */
public class ListConvertUtils {

    public static <T> T[] toArray(List<T> notExist) {
        T[] arrCopy = (T[]) Array.newInstance(notExist.get(0).getClass(), notExist.size());
        for (int i = 0; i < notExist.size(); i++) {
            Array.set(arrCopy, i, notExist.get(i));
        }
        return arrCopy;
    }
}
